/***********************************************************************
***LAST NAMES: XXXXXXX												***
***DATES: Oct 11, 2018												***
***CODES: Tables and Figures for "Power Sharing and the Rule of Law ***
in the Aftermath of Civil War"										***
***																	***
***********************************************************************/
 use lji_isq_paper
 
*TABLES


 *Table 1 Model 1;
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1)  panels (heteroskedastic) 

 *Table 1 Model 2;
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 negsett milvictory  if atwar==0, force corr(ar1)  panels (heteroskedastic) 
 
 *Table 1 Model 3
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0 &ten_years==1, force corr(ar1)  panels (heteroskedastic) 

 *Table 1 Model 4;
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_ngo log_oda_per_capita_dollar150 if atwar==0, force corr(ar1) panels (heteroskedastic) 
 
 *Table 1 Model 5;
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year jud_indep_3yrprior log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1) panels  (heteroskedastic) 
 
 /****************************************/
 
*Table 2 

*Model 6
 xtgls lji polps econps milps terrps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1)  panels (heteroskedastic) 

*Model 7
 xtgls lji polps econps milps terrps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 negset milvictory if atwar==0, force corr(ar1)  panels (heteroskedastic) 

*Model 8
 xtgls lji polps milps terrps econps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0 & ten_year==1, force corr(ar1) panels (heteroskedastic) 

	 
 /***********************************************/
 
 *FIGURES
 
 *Figure 1;
 xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1)  panels (heteroskedastic) 
 twoway scatter lji year if ccode ==192 & e(sample)

 *Figure 2;
 twoway scatter lji year if ccode ==558 & e(sample)
 
 *Figure 3;
 margins, at(numps=(0 1 2 3 4))
 marginsplot
 
 *Figure 4;
 keep if ccode==430 & (year>=1985 & year<=2010)
 twoway scatter lji year


 
/***************************************************/
*APPENDIX
****************************************************/


*TABLES
*Table 1 (Summary Statistics);
*In codes below, we removed additionally single observations for ccodes  that had only 1 observation in a group, and thus were removed from the models (i.e., ccode=384 from Model 1
*or ccode=800 and 384 from model 4);

*Summaries for variables used in Model 1;
use lji_isq_paper, replace
xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1)  panels (heteroskedastic)
summarize lji milvic negsett negtruce polps econps milps terrps highps if e(sample) & ccode !=384

*Considering that Model 5 used additional variable jud_indep_3yrprior, we generated summary for jud_indep_3yrprior after Model 5;
xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year jud_indep_3yrprior log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1) panels  (heteroskedastic) 
summarize jud_indep_3yrprior if e(sample) & ccode !=558 &ccode !=360 &ccode != 384 &ccode !=12 &ccode != 586 &ccode !=148

*Considering that Model 4 used additional variable log_ngo, we generated summary for ngo after Model 4;
xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_ngo log_oda_per_capita_dollar150 if atwar==0, force corr(ar1) panels (heteroskedastic) 
summarize ngo if e(sample)& ccode !=800 &ccode !=384
/***************************************************/

*Table 2;

xtpcse lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, correlation(ar1) hetonly


/***************************************************/
*Figure 1
xtgls lji numps lnwardur tsls chga_demo log_rgdppc british_colonialism mediation pko  y1999 lji_region_year log_wdi_pop  log_oda_per_capita_dollar150 if atwar==0, force corr(ar1)
predict lji_pr3 if e(sample)
generate resid_lji3= lji-lji_pr3
twoway scatter resid_lji3 lji_pr3
 
